

/**
 * Created by hehai on 17/1/18.
 */

import Foo.Foo;

public class Main {

    public static void main(String[] args){
//        Local local = new Local(new Remote(),"Hello");
//        local.sendMessage();


        Runnable r = new Runnable() {
            private Foo foo = new Foo();

            @Override
            public void run() {
                for (int i = 0; i < 3; i++) {
                    this.fix(30);
                    try {
                        Thread.sleep(1);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName() + " : 当前foo对象的x值= " + foo.getX());
                }
            }

            public synchronized int fix(int y) {
                return foo.fix(y);
            }
        };

        Thread ta = new Thread(r, "Thread-A");
        Thread tb = new Thread(r, "Thread-B");
        ta.start();
        tb.start();
    }

}
